<?php
	include "globals.php";
	
	if($ir['money'] < 500000){
		die("You don't have enough money. You need \$500,000.");
	}

	
	if($ir['gang']){
		die ("You're already in a gang!");
	}

	
	if($_POST['submit']){
		$name=htmlspecialchars($_POST['name']);
		$desc=htmlspecialchars($_POST['desc']);
		$db->query("INSERT INTO gangs VALUES('','$name','$desc','','',0,0,100,$userid,$userid,5,0,0,'')");
		$i=$db->insert_id();
		$db->query("UPDATE users SET gang=$i,money=money-500000 where userid=$userid");
		print "Gang created!";
	} else{
		print "<h3> Create A Gang </h3><form action='creategang.php' method='post'><input type='hidden' name='submit' value='1' />Name:<input type='text' name='name' /><br />Description:<br /> <textarea name='desc' cols='40' rows='7'></textarea> <br /><input type='submit' value='Create Gang for \$500,000' /></form>";
	}

	$h->endpage();
	?>